package com.best.design.strategy.bad;

/**
 * 优惠券类型
 * 1.直减券
 * 2.满减券
 * 3.折扣券
 * 4.n元购
 *
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2021/11/21
 **/
public class CouponDiscountService {

    public double discountAmount(int type, double typeContent, double skuPrice, double typeExt) {
        // 1. 直减券
        if (type == 1) {
            return skuPrice - typeContent;
        }
        // 2. 满减券
        if (type == 2) {
            if (skuPrice < typeExt) {
                return skuPrice;
            } else {
                return skuPrice - typeContent;
            }
        }
        // 3. 折扣券
        if (type == 3) {
            return skuPrice * typeContent;
        }
        // 4. n元购
        if (type == 4) {
            return typeContent;
        }
        return 0;
    }
}
